home *** CD-ROM | disk | FTP | other *** search
- /*
- © Copyright 1989 Apple Computer, Inc.
-
- By Ricardo Batista
-
-
- This file contains a code resource which is used within 4-Dimension
- to provide print queue management whitin 4D in Macintosh Portables.
-
- The idea is that when the user launches 4D, we take PrintMonitor out
- of the System Folder with a call to PrintQueue(), the effect of this is
- that if the user prints something from 4D PrintMonitor will not be
- launched and therefore it will not attempt to print and bother the user
- with messages, the user is using a Portable Macintosh and may not be
- connected to a network at the moment, therefore he just wants the print
- outs to be spooled but he doesn't want PrintMonitor to bother him.
- Once they quit 4D we restore the place of PrintMonitor. If the user
- goes to his office and connects to a network he'll want to print, for
- this he selects a menu option of 4D and we will restore PrintMonitor
- in the system folder so it is launched by Backgrounder.
-
- Notice that if the user selects the chooser to select a printer before
- he tell us he wants to print, background printing will be disabled from
- the chooser automatically by the laserwriter driver. (Maybe I'll do something
- about that)
-
- The other function we provide is management of the print queue within
- 4D, to dot this our ModifyPrintQueue() is called, which shows the current
- spooled files in a window, in this window we allow the user to change
- the print order. PrintMonitor uses the files named 'Spool File 1',
- 'Spool File 2', ...etc, to change the order all we need to do is rename
- these files, and change the name used to print a file can be taken out of the resource
- of each of these files, under 'STR ' -8189.
-
- Note: PrintMonitor prints the files based on their creation date, but we
- like to change the name to make it easier for us.
-
-
- HISTORY:
-
- 08/24/89 RB New Today
-
-
- SPECIAL INSTRUCTIONS:
-
- Compile in THINK C as a code resource, give the resource a name that will be used
- from 4D to call this external, then use 4D Ext Mover to copy into the Proc.Ext file
- of the database to have print queue management.
-
- */
-
-
-
-
-
-
- /*
- This is the main function of this 4D external command, we receive an integer
- parameter, if startQueue is non zero (true) then we hide print monitor inside
- the spool folder, otherwise we put printmonitor back in the system folder.
- If the spool folder does not exist we create it.
- */
-
- #include "SetupA4.h"
-
-
- pascal void main(int *startQueue)
- {
- CInfoPBRec info;
- CMovePBRec move;
- WDPBRec wd;
- int err = 0;
- SysEnvRec mac;
- long spoolFolder, pMonitorFolder;
-
- RememberA0();
- SetUpA4();
- err = SysEnvirons(1, &mac);
- wd.ioCompletion = 0L;
- wd.ioWDIndex = 0;
- wd.ioVRefNum = BootDrive;
- wd.ioNamePtr = 0L;
- wd.ioWDProcID = 0;
- err = PBGetWDInfo(&wd,FALSE);
- info.dirInfo.ioCompletion = 0L;
- if (mac.systemVersion < 0x7000)
- info.dirInfo.ioNamePtr = (StringPtr) "\pSpool Folder";
- else
- info.dirInfo.ioNamePtr = (StringPtr) "\pPrintMonitor Documents";
- info.dirInfo.ioVRefNum = BootDrive;
- info.dirInfo.ioFDirIndex = 0;
- info.dirInfo.ioDrDirID = 0;
- err = PBGetCatInfo(&info,FALSE);
- if (err == fnfErr) {
- if (mac.systemVersion < 0x7000)
- info.dirInfo.ioNamePtr = (StringPtr) "\pSpool Folder";
- else
- info.dirInfo.ioNamePtr = (StringPtr) "\pPrintMonitor Documents";
- err = CreateSpoolFolder(info.dirInfo.ioNamePtr);
- info.dirInfo.ioVRefNum = BootDrive;
- info.dirInfo.ioFDirIndex = 0;
- info.dirInfo.ioDrDirID = 0;
- err = PBGetCatInfo(&info,FALSE);
- }
- spoolFolder = info.dirInfo.ioDrDirID;
- pMonitorFolder = info.dirInfo.ioDrParID;
- if (mac.systemVersion >= 0x7000) {
- info.dirInfo.ioNamePtr = (StringPtr) "\pExtensions";
- info.dirInfo.ioVRefNum = BootDrive;
- info.dirInfo.ioFDirIndex = 0;
- info.dirInfo.ioDrDirID = 0;
- err = PBGetCatInfo(&info,FALSE);
- if (!err)
- pMonitorFolder = info.dirInfo.ioDrDirID;
- }
- if (!err) {
- if (*startQueue) {
- move.ioDirID = pMonitorFolder;
- move.ioNewDirID = spoolFolder;
- }
- else {
- move.ioDirID = spoolFolder;
- move.ioNewDirID = pMonitorFolder;
- }
- move.ioVRefNum = wd.ioWDVRefNum;
- move.ioCompletion = 0L;
- move.ioNewName = 0L;
- move.ioNamePtr = (StringPtr) "\pPrintMonitor";
- err = PBCatMove(&move,FALSE);
- }
- RestoreA4();
- return;
- asm {
- dc.b "© Copyright 1989 Apple Computer, Inc. By Ricardo Batista"
- }
- }
-
-
-
-
-
-
-
-
- /*
- This function will create a 'Spool Folder' inside the system folder, it
- is called when the Spool Folder was not found in the system folder as a
- precaution, because the user may have just installed the system and no
- spool folder exists.
- */
-
-
- int CreateSpoolFolder(char *fName)
- {
- HParamBlockRec hp;
- int err = 0;
-
- hp.ioParam.ioCompletion = 0L;
- hp.ioParam.ioNamePtr = (StringPtr) fName;
- hp.ioParam.ioVRefNum = BootDrive;
- hp.fileParam.ioDirID = 0;
- err = PBDirCreate(&hp,FALSE);
- return(err);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-